<template>
  <div>
    <el-col :span="24">
      <!-- <h5>默认颜色</h5> -->
      <el-menu
        :default-active="currentpath"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        style="background-color: rgba(236,236,235,0.3);"
        active-text-color="#ffd04b"
        router
        :unique-opened="true"
        v-if="userinfo"
      >
        <template v-for="(menu,i) in menus ">
          <template v-if="userinfo.roleid>=menu.role">
            <el-menu-item :key="i" :index="menu.path" v-if="!menu.children">
              <i :class="menu.icon"></i>
              <span slot="title">{{menu.text}}</span>
            </el-menu-item>

            <el-submenu v-else :key="i" :index="menu.path">
              <template slot="title">
                <i :class="menu.icon"></i>
                <span>{{menu.text}}</span>
              </template>
              <template v-for="(child,k) in menu.children">
                <el-menu-item :key="k" v-if="!child.hide" :index="child.path">
                  <i :class="menu.icon"></i>
                  <span slot="title">{{child.text}}</span>
                </el-menu-item>
              </template>
            </el-submenu>
          </template>
        </template>
      </el-menu>
    </el-col>
  </div>
</template>



<script>
import { menus } from "@/utils/menus";
export default {
  props: ["userinfo"],
  data() {
    return {
      menus,
      currentpath: this.$route.path,
    };
  },
  watch: {
    $route: function (to, from) {
      this.currentpath = to.path;
    },
  },
  methods: {
    handleOpen() {},
    handleClose() {},
  },
};
</script>

<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 199px;
  min-height: 400px;
  background: rgba(236, 236, 235, 0.1);
}
.el-menu-vertical-demo el-menu {
  background: rgba(236, 236, 235, 0.1);
}
</style>